<?php 

use yii\db\Query;
?>
<div class="col-xs-1 label label-lg label-info arrowed-in arrowed-right">
	<b>角色</b>
</div>
<div class="col-xs-5 label label-lg label-success arrowed-in arrowed-right">
	<b>模块下权限</b>
</div>
<div class="col-sm-6">
	<!-- #section:elements.tab.position -->
	<div class="tabbable tabs-left">
		<ul class="nav nav-tabs" id="myTab3" style="width: 140px;">
			<?php
				foreach ($roles as $r){
					//通过URL传递角色名称
					echo "<li>
					<a href=\"index.php?r=rbac/authassign&roleName=".$r['name']."\">".$r['description']."</a>
					</li>";
					
				}
			?>
			
		</ul>

		<div class="tab-content">
			<form action="index.php?r=rbac/authchild" method="post">
				<?php 
					//获取URL中的角色名称
					$roleName=(Yii::$app->request->get('roleName',"admin"));
					foreach ($controllerName as $c){
						
						echo "<label>".$c['description']."</label><br />";
						$controllerName=substr(strtolower($c['fileName']), 0,-10);
						$query=new Query();
						//autu_item表中查询控制器对应的操作名称
						$command=$query->select('*')->from('auth_item')->where("`type`=2 and `name` like '%".$controllerName."_%' ")->createCommand();
						$result=$command->queryAll();
						
						foreach($result as $r){
							
							echo "<label>
									<input name=\"permission[]\"  class=\"ace ace-checkbox-2\" type=\"checkbox\" value=\"".$r['name']."\" />
								<span class=\"lbl\">".$r['description']."</span>
							</label><br />";
						}
						echo "<input type=\"hidden\" name=\"rolename\" value=\"".$roleName."\" />";//角色信息加入到隐藏域中
						echo "<br />";
					}
					
				
				?>
				<br />
				<div>
					<button class="btn btn-info" type="submit">
						<i class="ace-icon fa fa-check bigger-110"></i>
						提交
					</button>
	
					&nbsp; &nbsp; &nbsp;
					<button class="btn" type="reset">
						<i class="ace-icon fa fa-undo bigger-110"></i>
						重置
					</button>
				</div>
			</form>	
		</div>
	</div>

	<!-- /section:elements.tab.position -->
</div>
